
public class CRUDUserTool {
	
	private boolean userExistsInDatabase;
	private User user;
	
	/**
	 * This creates a new CRUDUserTool with no user currently being worked on.
	 */
	public CRUDUserTool(){
		userExistsInDatabase = false;
		user = null;
	}
	
	/**
	 * This loads a user from the user database.  This does not load a user into the CRUDUserTool if the user can not be found in the database or the user that is
	 * currently being worked on in the database has been stored into the database or erased.
	 * 
	 * @return returns true if user is loaded into CRUDUserTool and false if the user is not loaded.
	 */
	public boolean loadUser(){
		if(user == null){
			//user = database.load();
			if(user != null){
				userExistsInDatabase = true;
				return true;
			}
		}
		return false;
	}
	
	/**
	 * This loads a new User into the CRUDUserTool.  This does not create a new user unless the user that is currently being worked on has been stored in the database or erased.
	 * 
	 * @return returns true if a new User is created and false if CRUDUserTool could not create a new user.
	 */
	public boolean newUser(){
		if(user == null){
			user = new User();
			userExistsInDatabase = false;
			return true;
		}
		return false;
	}
	
	/**
	 * Stores the user that is currently being worked on.
	 * 
	 * @return returns true if the user was stored into the database or false if the user could not be stored into the database or is null.
	 */
	public boolean storeUser(){  // needs more work if user exists in database already
		if(user != null){
			//database.save(user)
			// check if user was stored
			userExistsInDatabase = false;
			user = null;
			return true;
		}
		return false;
	}
	
	/**
	 * Erases the current user that is being worked on.
	 */
	public void eraseUser(){
		userExistsInDatabase = false;
		user = null;
	}
	
	
	
	
	public void deleteUser(){
		// deletes a user from the database
	}
	
	
	
	
	/**
	 *  updates the users username.
	 *  
	 *  @param username the new username of the user.
	 */
	public void updateUsername(String username){
		user.setUsername(username);
	}
	
	/**
	 * updates the password.
	 * 
	 * @param password the new password of the user.
	 */
	public void updatePassword(String password){
		user.setPassword(password);
	}
	
	public void updateSuspend(boolean suspend){
		user.setSuspend(suspend);
	}
	
	public void updateRoles(boolean[] roles){
		user.setRoles(roles);
	}
	
	public void updateName(String name){
		user.setName(name);
	}
	
	public void updateAddress(String address){
		user.setAddress(address);
	}
	
	public void updatePhone(String phone){
		user.setPhone(phone);
	}
	
	public void updateCellPhone(String cellPhone){
		user.setCellPhone(cellPhone);
	}
	
	public void updateEmail(String email){
		user.setEmail(email);
	}
	
	public void updateGender(Gender gender){
		user.setGender(gender);
	}
	
	public void updateBirthdate(Date date){
		user.setBirthdate(date);
	}
	
	public void updatePharmacy(String pharmacy){
		user.setPharmacy(pharmacy);
	}
	
	public void updateInsurance(String insurance){
		user.setInsurance(insurance);
	}
	
	public void updateAllergies(String allergies){
		user.setAllergies(allergies);
	}
	
	
	
	public User readUser(){
		return user;
	}
	
	public String readUsername(){
		return user.getUsername();
	}
	
	public String readPassword(){
		return user.getPassword();
	}
	
	public boolean readSuspend(){
		return user.getSuspend();
	}
	
	public boolean[] readRoles(){
		return user.getRoles();
	}
	
	public String readName(){
		return user.getName();
	}
	
	public String readAddress(){
		return user.getAddress();
	}
	
	public String readPhone(){
		return user.getPhone();
	}
	
	public String readCellPhone(){
		return user.getCellPhone();
	}
	
	public String readEmail(){
		return user.getEmail();
	}
	
	public Gender readGender(){
		return user.getGender();
	}
	
	public Date readBirthDate(){
		return user.getBirthDate();
	}
	
	public int readAge(){
		return user.getAge();
	}
	
	public String readPharmacy(){
		return user.getPharmacy();
	}
	
	public String readInsurance(){
		return user.getInsurance();
	}
	
	public String readAllergies(){
		return user.getAllergies();
	}
	
	public TreatmentRecord readNewestTreatment(){
		return user.getNewestTreatment();
	}
	
	public TreatmentRecord[] readTreatmentRecords(){
		return user.getTreatmentRecords();
	}
	
	
}
